import 'dart:io';
import 'dart:convert';

void main() {
  stdout.encoding = utf8;

  DateTime localTime = DateTime.now();
  DateTime utcTime = localTime.toUtc();

  DateTime newYorkTime = utcTime.subtract(Duration(hours: 4));

  DateTime cairoTime = utcTime.add(Duration(hours: 2));

  DateTime ukTime = utcTime.add(Duration(hours: 1));

  DateTime chinaTime = utcTime.add(Duration(hours: 8));

  print('Current time:');
  print('China time (CST): ${chinaTime}');
  print('New York time (EST): ${newYorkTime}');
  print('Cairo time (EET): ${cairoTime}');
  print('UK time (BST): ${ukTime}');
  print('UTC time: ${utcTime}');

  int daysToOffset = 1;

  DateTime newYorkOffsetLocal = newYorkTime.add(Duration(days: daysToOffset));

  DateTime utcOffset = utcTime.add(Duration(days: daysToOffset));
  DateTime newYorkOffsetFromUtc = utcOffset.subtract(Duration(hours: 4));

  print('\nTime after offsetting ${daysToOffset} days:');
  print('Offset using New York local time: ${newYorkOffsetLocal}');
  print(
    'Offset using UTC time and then convert to New York time: ${newYorkOffsetFromUtc}',
  );
}
